{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="{% static 'js/jquery-1.12.4.min.js' %}"></script>
    <script>
        $(function () {
            // c1选择
            $('#c1').change(function () {

                $.get('/deploy/city_handle/', {'code': $(this).val()}, function (data) {
                    city_list = data.ret;
                    //　清空子标签
                    $('#c2').empty();
                    $('#c2').append('<option value="-1">请选择市</option>');
                    $('#c3').empty();
                    $('#c3').append('<option value="-1">请选择区县</option>');
                    //　追加子标签
                    for (var i=0; i<city_list.length;++i)
                    {
                        ele = '<option value="'+ city_list[i].code +'">'+ city_list[i].name +'</option>'
                        $('#c2').append(ele)
                    }
                });
            });
            // c2选择
            $('#c2').change(function () {
                 $.get('/deploy/city_handle/', {'code': $(this).val()}, function (data) {
                    city_list = data.ret;
                    //　清空子标签
                    $('#c3').empty();

                    $('#c3').append('<option value="-1">请选择区县</option>')
                    //　追加子标签
                    for (var i=0; i<city_list.length;++i)
                    {
                        ele = '<option value="'+ city_list[i].code +'">'+ city_list[i].name +'</option>'
                        $('#c3').append(ele)
                    }
                });
            });

        });
    </script>
</head>
<body>

<select id="c1">
    <option value="-1">请选择</option>
    {% for city in cities %}
        <option value="{{ city.area_code }}">{{ city.area_name }}</option>
    {% endfor %}
</select>
<select id="c2">
    <option value="-1">请选择市</option>
</select>
<select id="c3">
    <option value="-1">请选择区县</option>
</select>

</body>
</html>